package com.example.demo.Impl;

import com.example.demo.entity.MbtiResult;
import com.example.demo.repository.MbtiResultRepository;
import com.example.demo.service.MbtiResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MbtiResultServiceImpl implements MbtiResultService {

    @Autowired
    private MbtiResultRepository resultRepository;

    @Override
    public List<MbtiResult> getAll() {
        return resultRepository.findAll();
    }

    @Override
    public List<MbtiResult> getByStudentId(Long studentId) {
        return resultRepository.findByStudentId(studentId);
    }

    @Override
    public List<MbtiResult> getByClassId(Long classId) {
        return resultRepository.findByStudent_Clazz_Id(classId);
    }

    @Override
    public List<MbtiResult> getByClazzId(Long classId) {
        return List.of();
    }

    @Override
    public List<MbtiResult> getByMajorId(Long majorId) {
        return resultRepository.findByStudent_Clazz_ParentId(majorId);
    }

    @Override
    public List<MbtiResult> getByCollegeId(Long collegeId) {
        return List.of();
    }

    @Override
    public List<MbtiResult> getByCollegeIds(List<Long> collegeIds) {
        // 学院对应的是多个 parentId 的列表
        return resultRepository.findByStudent_Clazz_ParentIdIn(collegeIds);
    }

    @Override
    public MbtiResult save(MbtiResult result) {
        return resultRepository.save(result);
    }
}
